package com.feng.chatCient.mock;

import com.feng.chatCient.entiry.User;
import com.feng.chatCient.util.RandomUtil;
import com.feng.chatCient.util.StringUtils;


import java.util.ArrayList;
import java.util.List;

public class UserAccountMock {
    private static int userMockCount = 20;
    private static String[] nickNames = new String[userMockCount];
   private static List<User> userList = new ArrayList<>();
    static {
        initData();
        initMockUserList();
    }

    private static void initData() {
        nickNames = new String[]{"小敏", "小红", "小王", "小张", "小凡", "张三", "sam", "ken", "jim", "王二",
                "小敏2", "小红2", "小王2", "小张2", "小凡2", "张三2", "sam2", "ken2", "jim2", "无名"};
    }

    public static List<User> getUserList() {
        return userList;
    }


    public static List<User> initMockUserList() {

        for (int i = 0; i < userMockCount; i++) {
            User user = new User();
            user.setAccount(RandomUtil.getRandomForLongBounded(1000000L, 900000000000L) + "");
            String nickName = nickNames[i];
            if (nickName == null) {
                nickName = "acount" + i;
            }
            user.setNickName(nickName);
            user.setPassword("111111");
        }
        return userList;
    }


    public static User getUserByName(String account){
        for(User user : userList){
          String userAccount =  user.getAccount();
            if(StringUtils.isNotNull(userAccount)&&user.equals(account)){
                return user;
            }
        }
        return null;
    }
}
